﻿using System;
using System.Collections.Generic;
using System.Text;
using com.lover.astd.common.logic;
using com.lover.astd.common.model;

namespace com.lover.astd.common.logicexe.equip
{
    public class DailyWeaponExe : ExeBase
    {
        public DailyWeaponExe() { _name = ConfigStrings.S_DailyWeapon; _readable = ConfigStrings.SR_DailyWeapon; }
        public override long execute()
        {
            if (_user.Level < 120) return next_day();
            Dictionary<string, string> conf = getConfig();
            if (conf.ContainsKey(ConfigStrings.enabled) && conf[ConfigStrings.enabled].ToLower().Equals("true"))
            {
                if (conf.ContainsKey(ConfigStrings.daily) && conf[ConfigStrings.daily] != "")
                {
                    string daily = conf[ConfigStrings.daily];
                    bool hasGotToday = false;
                    int result = ServiceFactory.getEquipManager().handleDailyWeapon(_proto, _logger, out hasGotToday, daily);
                    if (hasGotToday) return next_day();
                    else if (result == 3) { logInfo(String.Format("未找到所需要的兵器:{0}",daily)); return an_hour_later(); }
                    else return immediate();
                }
            }
            return next_day();
        }
    }
}
